import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { LayerManager } from "../../manager/LayerManager";
import { Global } from "../../../../com/gengine/global/Global";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { SecTimerView } from "../common/SecTimerView";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { EffectManager } from "../../manager/EffectManager";
import { EGuildwarState } from "./defin/EGuildwarState";
import { ClockManager } from "../../manager/ClockManager";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class GuildWarIconView
    
    export  class GuildWarIconView extends ActiveBaseIcon
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.x = Global.stage.stageWidth - 355;
            this.y = 10;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._btnIcon = ObjCreate.createGLoadedButton(ResFileConst.guildWarBtn, 5, 0, 50, 50, this);
            this._secTimeText = new SecTimerView();
            this._secTimeText.y = 52;
            this._secTimeText.x = 0;
            this._secTimeText.width = 80;
            this._secTimeText.height = 20;
            this._secTimeText.defaultTextFormat = GlobalStyle.textFormat5;
            this._secTimeText.filters = [FilterConst.glowFilter];
            this._secTimeText.mouseEnabled = false;
            this.addChild(this._secTimeText);
            this._btnIcon.addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            return;
        }

        public showGuildWarEffect(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                loc1 = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
                loc2 = [loc1];
                EffectManager.glowFilterReg(this._btnIcon, loc2, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._btnIcon);
            }
            return;
        }

        public updateState(arg1: EGuildwarState, arg2: Date): void
        {
            var loc1=(arg2.time - ClockManager.instance.nowDate.time) / 1000;
            var loc2=arg1;
            switch (loc2) 
            {
                case EGuildwarState.SignUp:
                {
                    this._secTimeText.setParse(Language.getString(41816));
                    break;
                }
                case EGuildwarState.Enter:
                {
                    this._secTimeText.setParse(Language.getString(41817));
                    break;
                }
                case EGuildwarState.Open:
                {
                    this._secTimeText.setParse(Language.getString(41818));
                    break;
                }
            }
            this.updateLeftTime(loc1);
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._secTimeText.setLeftTime(arg1);
            return;
        }

        /* internal  */onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarShowOpenModule));
            return;
        }

        public static get instance(): GuildWarIconView
        {
            if (!GuildWarIconView._instance) 
            {
                GuildWarIconView._instance = new GuildWarIconView();
            }
            return GuildWarIconView._instance;
        }

        /* internal */ /* var */_btnIcon: GLoadedButton;

        /* internal */ /* var */_secTimeText: SecTimerView;

        /* internal */ static /* var */_instance: GuildWarIconView;
    }
